import request from '@/utils/request'

/**
 * 获取积分余额
 */
export const getPointsBalance = () => {
  return request.get('/api/points/balance')
}

/**
 * 获取积分统计
 */
export const getPointsStats = () => {
  return request.get('/api/points/stats')
}

/**
 * 获取积分记录
 */
export const getPointsHistory = (params = {}) => {
  return request.get('/api/points/history', { params })
}

/**
 * 消费积分
 */
export const consumePoints = (data) => {
  return request.post('/api/points/consume', data)
}

/**
 * 获得积分
 */
export const earnPoints = (data) => {
  return request.post('/api/points/earn', data)
}

/**
 * 积分转账
 */
export const transferPoints = (data) => {
  return request.post('/api/points/transfer', data)
}

/**
 * 管理员调整积分
 */
export const adjustPoints = (data) => {
  return request.post('/api/points/admin/adjust', data)
}

/**
 * 积分相关API
 */
export default {
  /**
   * 获取积分余额
   */
  getPointsBalance() {
    return request.get('/api/points/balance')
  },

  /**
   * 获取积分记录
   * @param {Object} params - 查询参数
   */
  getPointsHistory(params = {}) {
    return request.get('/api/points/history', { params })
  },

  /**
   * 获取积分统计
   */
  getPointsStats() {
    return request.get('/api/points/stats')
  },

  /**
   * 消费积分
   * @param {Object} data - 消费数据
   */
  consumePoints(data) {
    return request.post('/api/points/consume', data)
  },

  /**
   * 获得积分
   * @param {Object} data - 获得数据
   */
  earnPoints(data) {
    return request.post('/api/points/earn', data)
  },

  /**
   * 积分转账
   * @param {Object} data - 转账数据
   */
  transferPoints(data) {
    return request.post('/api/points/transfer', data)
  },

  /**
   * 管理员调整积分
   * @param {Object} data - 调整数据
   */
  adjustPoints(data) {
    return request.post('/api/points/admin/adjust', data)
  },

  /**
   * 每日签到
   */
  dailyCheckin() {
    return request.post('/api/points/checkin')
  },

  /**
   * 获取签到状态
   */
  getCheckinStatus() {
    return request.get('/api/points/checkin/status')
  },

  /**
   * 观看广告获得积分
   */
  watchAd() {
    return request.post('/api/points/watch-ad')
  }
}